<!--
 * @Description: 企业微信信息录入
 * @Version: 1.0
 * @Author: Yuanjy
 * @Date: 2020-03-13 19:56:08
 * @LastEditors: Yuanjy
 * @LastEditTime: 2020-05-10 12:18:05
 -->
<template>
  <div class="app-container">
    <el-form ref="form" :model="enterprise" size="small" label-width="130px">
      <el-form-item label="企业名称" prop="corp_name">
        <span v-html="enterprise.corp_name" />
      </el-form-item>
      <el-form-item label="企业corpid" prop="corpid">
        <span v-html="enterprise.corpid" />
      </el-form-item>
      <el-form-item label="自建应用的agentid" prop="secret">
        <el-input v-model="enterprise.self_agentid" style="width:300px;" />
      </el-form-item>
      <el-form-item label="自建应用的secret" prop="secret">
        <el-input v-model="enterprise.self_secret" style="width:300px;" />
      </el-form-item>
      <el-form-item label="微信公众号appid" prop="secret">
        <el-input v-model="enterprise.wechat_appid" style="width:300px;" />
      </el-form-item>
      <el-form-item label="小程序appid">
        <el-input v-model="enterprise.mini_appid" style="width:300px;" />
      </el-form-item>
      <el-form-item label="小程序secret">
        <el-input v-model="enterprise.mini_secret" style="width:300px;" />
      </el-form-item>
    </el-form>
    <div class="empty-10" />
    <el-button :loading="loading" size="small" type="primary" style="margin-left:30px;" @click="doSubmit"> 确认修改 </el-button>
  </div>
</template>

<script>

export default {
  data() {
    return {
      loading: false, dialog: false,
      enterprise: {
        corp_name: '',
        corpid: '',
        self_agentid: '',
        self_secret: '',
        wechat_appid: '',
        mini_appid: '',
        mini_secret: '',
      }
    }
  },
  created() {
    this.initData()
  },
  methods: {
    initData() {
      this.$api.enterprise.enterprise
        .detail()
        .then(res => {
          this.enterprise = res.data
        }).catch(err => {
          console.log(err)
        })
    },
    doSubmit() {
      this.$api.enterprise.enterprise
        .updateBasic({
          data: this.enterprise
        })
        .then(res => {
          this.$notify({ title: '修改成功', type: 'success', duration: 2500 })
          this.loading = false
          this.sup_this.init()
        }).catch(err => {
          this.loading = false
          console.log(err)
        })
    }
  }
}
</script>

<style scoped>

</style>
